//
   Created by wanthering on 2017/8/17.

html
    head
        mata(name='shareId' content= id)
        mata(name='shareDesc' content= desc)
        mata(name='shareTitle' content= title)
        mata(name='faceUrl' content= faceUrl)
        meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
        meta(name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=0")
        meta(name="apple-mobile-web-app-status-bar-style" content="black")
        meta(name="apple-mobile-web-app-capable" content="yes")
        meta(content="yes" name="apple-touch-fullscreen")
        meta(name="format-detection" content="telephone=no, email=no")
        title= "【点击入群】"+title
        link(rel="stylesheet" href="/stylesheets/qrcode.css")
    body
        .modal
            p.join
            img(src= qunUrl width="96%")
            a(href="../audios/"+id class="back") 返回
    script(src="/javascripts/jquery-1.11.3.min.js")
    script(src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js")
    script(type='text/javascript').
      var shareDesc = $('mata[name=shareDesc]').attr('content')
      var shareTitle = $('mata[name=sharetitle]').attr('content')
      var shareItemUrl = $('mata[name=faceUrl]').attr('content') + '-item'
      var shareId = $('mata[name=shareId]').attr('content')
      var APPID = 'wx92f602d76b0c05bc';
      $.ajax({
        type: 'post',
        url: 'https://www.enjoyshadow.com:10333/signature',
        data: {'url': window.location.href},
        dataType: 'json',
        success: function (d) {
          console.log(d);
          wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: APPID, // 必填，公众号的唯一标识
            timestamp: d.params.timestamp, // 必填，生成签名的时间戳
            nonceStr: d.params.noncestr, // 必填，生成签名的随机串
            signature: d.params.signature,// 必填，签名，见附录1
            jsApiList: ['onMenuShareTimeline',
              'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
          });

          wx.ready(function () {
            wx.onMenuShareTimeline({
              title: shareTitle, // 分享标题
              link: "http://audio.enjoyshadow.com/audios/" + shareId, // 分享链接
              imgUrl: shareItemUrl // 分享图标
            });

            wx.onMenuShareAppMessage({
              title: shareTitle, // 分享标题
              link: "http://audio.enjoyshadow.com/audios/" + shareId, // 分享链接
              desc: shareDesc, // 分享描述
              imgUrl: shareItemUrl // 分享图标
            });
          });

        }
      })